package player.state;

import jaco.mp3.player.MP3Player;
import player.MusicPlayer;

/**
 * Pause state of the music player.
 * @author Pawin Suthipornopas 5510546123
 */
public class PauseState extends PlayerState {
	
	/**
	 * Constructor, create the playing state.
	 * @param player is the player to be played.
	 * @param musicPlayer is the MusicPlayer, use to change the state.
	 */
	public PauseState(MP3Player player, MusicPlayer musicPlayer){
		super(player, musicPlayer);
	}

	@Override
	public void handlePlay() {
		player.play();
		musicPlayer.setState(musicPlayer.PLAYING_STATE);
		System.out.println("PauseState_handlePlay");
	}

	@Override
	public void handleStop() {
		player.stop();
		musicPlayer.setState(musicPlayer.IDLE_STATE);
		System.out.println("PauseState_handleStop");
	}

	@Override
	public void handlePause() {
		player.play();
		musicPlayer.setState(musicPlayer.PLAYING_STATE);
		System.out.println("PauseState_handlePause");
	}

	@Override
	public void handleNext() {
		player.stop();
		player.skipForward();
		musicPlayer.setState(musicPlayer.PLAYING_STATE);
		System.out.println("PauseState_handleNext");
		
	}

	@Override
	public void handlePrevious() {
		player.stop();
		player.skipBackward();
		musicPlayer.setState(musicPlayer.PLAYING_STATE);
		System.out.println("PauseState_handlePrevious");
	}

}
